package com.xiaoyang.ssyx;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @AUTHOR XiaoYang
 * @DATE 2023/7/3-15:31
 * @DESCRIPTION TODO runAsync方法不支特返回值
 */
public class CompletableFutureDemo1 {
    public static void main(String[] args) {
        //创建线程池（实际中不这么做）
        ExecutorService executorService = Executors.newFixedThreadPool(3);

        System.out.println("main begin...");

        //CompletableFuture创建异步对象
        CompletableFuture<Void> completableFuture = CompletableFuture.runAsync(() -> {
            System.out.println("now thread :" + Thread.currentThread().getName());
            int result = 1024;
            System.out.println("result :" + result);
        }, executorService);
        System.out.println("main over...");
    }
}
